/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pattern;

import java.util.ArrayList;

/**
 *
 * @author jccaicedo
 */
public class NameList {

    private ArrayList<String> names;
    private SortStrategy sortAlgorithm;

    public NameList(SortStrategy strategy){
        this.sortAlgorithm = strategy;
        names = new ArrayList<String>();
    }

    public void addName(String name){
        names.add(name);
    }

    public void printList(){
        sortAlgorithm.sort(names);
        for(String name: names){
            System.out.println(name);
        }
    }

    public void printList(SortStrategy newStrategy){
        this.sortAlgorithm = newStrategy;
        printList();
    }
}
